﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace LuckyFish.Blog.Models;

public class ArticleModel
{
    [Key]
    [Column(TypeName = "varchar(256)")]
    [Required(ErrorMessage = "未设置文章链接")]
    public string UrlName { get; set; }

    [Required(ErrorMessage = "未设置标题")] public string Title { get; set; }
    public string? ImageUrl { get; set; }
    public string? Brief { get; set; }
    public string HtmlContext { get; set; }
    [Required] public string DateString { get; set; }
    
    public List<LabelList> Labels { get; set; } = new();
    
    public string? ListId { get; set; }
    public ArticleList? List { get; set; }

    public override string ToString()
        => $"标题:{Title}\n路径;{UrlName}\n" +
           $"描述:{Brief}\n图片路径:{ImageUrl}\n" +
           $"Html内容:{HtmlContext}\n" +
           $"时间:{DateString}";
    
    public bool IsNull()
        => string.IsNullOrEmpty(UrlName) || string.IsNullOrEmpty(Title) || string.IsNullOrEmpty(HtmlContext);
}